/*
 * ButtonSprite is a Sprite subclass.
 */

ButtonSprite.prototype = new Sprite();

function ButtonSprite(text, context, x, y, width, height, clickCallback, hoverCallback) {
		
	Sprite.call(this, context, x, y, width, height, clickCallback, this.hoverCallback);
		 	
	this.text = text;
	this.textWidth = this.context.measureText(this.text).width;																								

	this.initImage("#003366");	
}

ButtonSprite.prototype.initImage = function(fillStyle) {
		
	this.imageContext.font = "bold 70px Helvetica";
	this.imageContext.lineWidth = 5;
	
	if(this.isHovered) {
		this.imageContext.fillStyle = "#AA3366";
	}		
	else {
		this.imageContext.fillStyle = "#003366";
	}	
	
	this.textWidth = this.imageContext.measureText(this.text).width;	
	var buttonTextOne = this.text;
				
	this.imageContext.strokeStyle = "#000000";		
	
	this.imageContext.strokeCircle(0.5 * this.width,
												0.5 * this.height, 		
												0.62 * this.height);
		
	this.imageContext.fillRoundRect(0, 0, this.width, this.height, 30);
	this.imageContext.fillStyle = "#554466";
	this.imageContext.fillCircle(0.5 * this.width,
											0.5 * this.height, 		
											0.6 * this.height);
	this.imageContext.strokeRoundRect(0, 0, this.width, this.height, 60);										
	
	this.imageContext.strokeStyle = "#554466";
	this.imageContext.fillStyle = "#8A8A8A";
	this.imageContext.lineWidth = 3;				
	
	if(this.isClicked) {
		this.imageContext.fillStyle = "#000000";
	}
	
	this.imageContext.fillText(buttonTextOne, 
										this.width - this.textWidth,									
										0.7 * this.height);
	
	this.imageContext.strokeText(buttonTextOne, 
											this.width - this.textWidth,
											0.7 * this.height);																					 		 			
}